#ifndef CXXOMFORT_CXXOLITERALS_AFFIX_HEXDUMP_HPP
#define CXXOMFORT_CXXOLITERALS_AFFIX_HEXDUMP_HPP

#include <cxxomfort/base.hpp>
#include <vector>
#include <array>
#include <cstdio>
#include "../literals.hpp"

namespace cxxomfort { namespace library { 
namespace literals {

template <size_t N>
std::array<char,N/2> read_hexdump (char const (&p)[N]) {
	using namespace std;
	std::array<char,N/2> rd;
	for (size_t i= 0; i < N/2; ++i) {
		char c;
		sscanf(&(p[2*i]), "%02hhx", &c);
		//cout<< "Read ("<< c<< ") "<< flush;
		rd[i] = c;
	}
	return rd;
}

const struct hxd_t
: public cxxomfort::literals::impl::affix_definition8<std::vector<char>, hxd_t >
{
	template <size_t N>
	std::vector<char> operator() (char const (&p)[N]) const {
		using namespace std;
		std::vector<char> rd(N/2);
		for (size_t i= 0; i < N/2; ++i) {
			char c;
			sscanf(&(p[2*i]), "%02hhx", &c);
			//cout<< "Read ("<< c<< ") "<< flush;
			rd[i] = c;
		}
		return rd;
	}
	
} hxd;



}

} }

#endif

